package com.agent.crm.view;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.agent.crm.base.BaseActivity;

public class LoginActivity extends BaseActivity {
	
	private Button btn_login;
	private EditText password;
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_login:
			SharedPreferences preferences =getSharedPreferences("login_data", Context.MODE_PRIVATE);
			String pass=preferences.getString("password", "123456");
			if("".equalsIgnoreCase(password.getText().toString())||null==password.getText().toString()){
				showSimpleAlertDialog("请输入密码！！");
				return;
			}
			if(pass.equalsIgnoreCase(password.getText().toString())){
				Editor editor =preferences.edit();
				editor.putString("isLogin", "true");
				editor.commit();
				Intent intent = new Intent();
        		intent.setClass(LoginActivity.this, MainActivity.class);
        		startActivity(intent);
        		finish();
			}else{
				showSimpleAlertDialog("提示", "密码错误");
				return;
			}
			break;

		default:
			break;
		}
	}

	@Override
	protected int initLayout() {
		// TODO Auto-generated method stub
		return R.layout.login;
	}

	@Override
	protected View initCustomLayout() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void initViewCmp() {
		// TODO Auto-generated method stub
		btn_login =(Button)findViewById(R.id.btn_login);
		password =(EditText)findViewById(R.id.password);
		
	}

	@Override
	protected void initListener() {
		// TODO Auto-generated method stub
		btn_login.setOnClickListener(this);
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void initAsycnData() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void changeDefaultSetting() {
		// TODO Auto-generated method stub
		
	}

}
